package top.likeqc.leetcode.editor.cn;

import java.util.HashMap;
import java.util.Map;

/**
 * @see <a href="https://leetcode.cn/problems/determine-color-of-a-chessboard-square">leetcode题库</a>
 */
public class DetermineColorOfAChessboardSquare {
    public static void main(String[] args) {
        Solution solution = new DetermineColorOfAChessboardSquare().new Solution();
        System.out.println(solution.squareIsWhite("a1"));
        System.out.println(solution.squareIsWhite("h3"));
        System.out.println(solution.squareIsWhite("c7"));
    }
    // leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        Map<String, Boolean> map = new HashMap<>();

        public boolean squareIsWhite(String coordinates) {
            if (map.containsKey(coordinates)) {
                return map.get(coordinates);
            }
            int x = coordinates.charAt(0) - 'a';
            int y = coordinates.charAt(1) - '1';

            boolean g = (x % 2 != y % 2);

            map.put(coordinates, g);

            return map.get(coordinates);
        }
    }
    // leetcode submit region end(Prohibit modification and deletion)

}
